#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/module.h>
void xdev_release(struct device *dev)
{
    printk("xdev release \n");
}
extern struct bus_type xbus;

struct device xdev = {
    .init_name = "wangcai",
    .bus = &xbus,
    .release = xdev_release,
};

int test_init(void)
{
    int ret;
    ret = device_register(&xdev);
    if (ret < 0)
    {
        printk("device register is error\n");
        return -1;
    }
    printk("insmod xdev\n");
    return 0;
}
void test_exit(void)
{
    device_unregister(&xdev);
    printk("rmmod xdev\n");
}
MODULE_LICENSE("GPL");
module_init(test_init);
module_exit(test_exit);